package com.ankicoo.database.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ankicoo.common.response.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * Description:
 *
 * @author : QCYANG
 * @date : 2021/11/17 11:20
 */
@RestController
@RequestMapping("jdbc")
public class JdbcTemplateController {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @GetMapping("/countUser")
    public Integer countUser(){
        return jdbcTemplate.queryForObject("select count(1) from AUTH_USER", Integer.class);
    }

    @GetMapping("/getData")
    public ResponseBody<Object> getData(){

        List<Map<String, Object>> maps = jdbcTemplate.queryForList("select * from AUTH_USER");
        return ResponseBody.createBySuccess(maps);
    }
}
